<?php 
	// $this->breadcrumbs = array(
	// 'Rights'=>Rights::getBaseUrl(),
	// Rights::getAuthItemTypeNamePlural($model->type)=>Rights::getAuthItemRoute($model->type),
	// $model->name,
	// ); 
?>
<?php //$this->renderPartial('_form', array('model'=>$formModel)); 
	// $mn = "Roles";
	// $link = Yii::app()->createUrl('rights/authItem/roles');
	// $rg = Rights::t('core', 'Create :type', array(
							// ':type'=>Rights::getAuthItemTypeName($_GET['type']),
						// ));
	// if($rg=="Create Task"){
		// $mn = "Tasks";
		// $link = Yii::app()->createUrl('rights/authItem/tasks');
	// }
	// if($rg=="Create Operation"){
		// $mn = "Operation";
		// $link = Yii::app()->createUrl('rights/authItem/tasks');
	// }
?>
<div class="breadcrumbs" id="breadcrumbs">
	<ul class="breadcrumb">
		<li><i class="icon-home home-icon"></i><a href="#">Home</a></li>
		<li><a href="<?php Rights::getBaseUrl(); ?>">Access Role</a></li>
		
		<li class="active"><?php echo Rights::t('core', 'Update :name', array(
						':name'=>$model->name,
						':type'=>Rights::getAuthItemTypeName($model->type),
					)); ?></li>
	</ul>
	<script type="text/javascript">
		try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
	</script>
</div>
<div class="col-xs-12">
	<div class="page-content">
		<div class="page-header">
			<div class="clearfix">
				<div class="pull-left">
					<h1><?php echo Rights::t('core', 'Update :name', array(
						':name'=>$model->name,
						':type'=>Rights::getAuthItemTypeName($model->type),
					)); ?></h1>
				</div>
				<div class="pull-right">
					<div class="btn-toolbar inline middle no-margin">
						<div class="btn-group">
							<a title="Assignments" href="<?php echo Yii::app()->createUrl('rights/assignment/view'); ?>" class="btn btn-sm "><i class="icon-file"></i>&nbsp;&nbsp;Assignments</a>
							<a title="Permissions" href="<?php echo Yii::app()->createUrl('rights/authItem/permissions'); ?>" class="btn btn-sm "><i class="icon-file"></i>&nbsp;&nbsp;Permissions</a>
							<a title="Roles" href="<?php echo Yii::app()->createUrl('rights/authItem/roles'); ?>" class="btn btn-sm "><i class="icon-file"></i>&nbsp;&nbsp;Roles</a>
							<a title="Tasks" href="<?php echo Yii::app()->createUrl('rights/authItem/tasks'); ?>" class="btn btn-sm "><i class="icon-file"></i>&nbsp;&nbsp;Tasks</a>
							<a title="Operations" href="<?php echo Yii::app()->createUrl('rights/authItem/operations'); ?>" class="btn btn-sm "><i class="icon-file"></i>&nbsp;&nbsp;Operations</a>
						</div>
					</div>
				</div>
			</div>
		</div>
		
		<div class="col-xs-12">
			
			<?php $this->renderPartial('_form', array('model'=>$formModel)); ?>
			
			<div class="relations span-11 last">

				<h3><?php echo Rights::t('core', 'Relations'); ?></h3>

				<?php if( $model->name!==Rights::module()->superuserName ): ?>

					<div class="parents">

						<h4><?php echo Rights::t('core', 'Parents'); ?></h4>

						<?php $this->widget('zii.widgets.grid.CGridView', array(
							'dataProvider'=>$parentDataProvider,
							'template'=>'{items}',
							'hideHeader'=>true,
							'emptyText'=>Rights::t('core', 'This item has no parents.'),
							'htmlOptions'=>array('class'=>'grid-view parent-table mini'),
							'columns'=>array(
								array(
									'name'=>'name',
									'header'=>Rights::t('core', 'Name'),
									'type'=>'raw',
									'htmlOptions'=>array('class'=>'name-column'),
									'value'=>'$data->getNameLink()',
								),
								array(
									'name'=>'type',
									'header'=>Rights::t('core', 'Type'),
									'type'=>'raw',
									'htmlOptions'=>array('class'=>'type-column'),
									'value'=>'$data->getTypeText()',
								),
								array(
									'header'=>'&nbsp;',
									'type'=>'raw',
									'htmlOptions'=>array('class'=>'actions-column'),
									'value'=>'',
								),
							)
						)); ?>

					</div>

					<div class="children">

						<h4><?php echo Rights::t('core', 'Children'); ?></h4>

						<?php $this->widget('zii.widgets.grid.CGridView', array(
							'dataProvider'=>$childDataProvider,
							'template'=>'{items}',
							'hideHeader'=>true,
							'emptyText'=>Rights::t('core', 'This item has no children.'),
							'htmlOptions'=>array('class'=>'grid-view parent-table mini'),
							'columns'=>array(
								array(
									'name'=>'name',
									'header'=>Rights::t('core', 'Name'),
									'type'=>'raw',
									'htmlOptions'=>array('class'=>'name-column'),
									'value'=>'$data->getNameLink()',
								),
								array(
									'name'=>'type',
									'header'=>Rights::t('core', 'Type'),
									'type'=>'raw',
									'htmlOptions'=>array('class'=>'type-column'),
									'value'=>'$data->getTypeText()',
								),
								array(
									'header'=>'&nbsp;',
									'type'=>'raw',
									'htmlOptions'=>array('class'=>'actions-column'),
									'value'=>'$data->getRemoveChildLink()',
								),
							)
						)); ?>

					</div>

					<div class="addChild">

						<h5><?php echo Rights::t('core', 'Add Child'); ?></h5>

						<?php if( $childFormModel!==null ): ?>

							<?php $this->renderPartial('_childForm', array(
								'model'=>$childFormModel,
								'itemnameSelectOptions'=>$childSelectOptions,
							)); ?>

						<?php else: ?>

							<p class="info"><?php echo Rights::t('core', 'No children available to be added to this item.'); ?>

						<?php endif; ?>

					</div>

				<?php else: ?>

					<p class="info">
						<?php echo Rights::t('core', 'No relations need to be set for the superuser role.'); ?><br />
						<?php echo Rights::t('core', 'Super users are always granted access implicitly.'); ?>
					</p>

				<?php endif; ?>

			</div>
			
		</div><!-- /span -->
		
	</div>
</div>